package com.qf;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.qf.model.Device;
import com.qf.utils.JedisPoolUtil;
import org.junit.Test;
import redis.clients.jedis.Jedis;

public class Demo02 {
    /**
     * 字符串存储对象
     **/
    @Test
    public void test01() throws Exception{
        Device device = new Device();
        device.setId(1111);
        device.setDeviceName("层压机");
        device.setPrice(30000D);
        device.setCompany("杭州小层有限公司");
        device.setType("压力机");

        ObjectMapper objectMapper = new ObjectMapper();
        String s = objectMapper.writeValueAsString(device);

        Jedis jedis = JedisPoolUtil.getResource();
        jedis.select(5);

        System.out.println(jedis.set("device" + device.getId(), s));

        System.out.println(jedis.get("device" + device.getId()));

        jedis.close();

    }


}
